package cn.hls.web.controller.biz;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.hls.entity.SmsAdvice;
import cn.hls.entity.vo.Msg;
import cn.hls.entity.vo.PageInfo;
import cn.hls.service.SmsAdviceService;
import cn.hls.web.controller.base.BaseController;


/**
  *@fileName: SmsAdviceController.java
  *@package: cn.hls.web.controller.biz
　*@Description:短信发送控制器
　*@author: yinghui.zhang
　*@email: uuhui@163.com
  *@date: 2016年12月25日
 *
 */
@Controller
@RequestMapping("/smsAdvice")
public class SmsAdviceController extends BaseController<SmsAdvice> {
	@Resource(name = "smsAdviceService")
	private SmsAdviceService service;
	
	 
	/**
	 * 表单
	 * 
	 * @param id 编号
	 * @param show 是否查看操作 true:查看操作 false:新增或修改操作
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/info")
	public ModelAndView info(Long id,Integer type, boolean show )
			throws Exception {
		SmsAdvice entity = null;
		ModelAndView modelAndView=new ModelAndView();
		if (id != null) {
			entity = service.find(id);
		}
		modelAndView.addObject("entity",entity);
		if (show) {
			modelAndView.setViewName("sms/advice_show");
		} else {
			modelAndView.setViewName("sms/advice_info");
		}
		return modelAndView;
	}


	 
	/**
	 * 删除操作
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("/del")
	public Msg del(String ids) throws Exception {
		String[] tempIds = ids.split("\\,");
		service.delete(tempIds);
		return msg;
	}
	 

	/**
	 * 分页查询
	 * @param entity 查询的会友对象
	 * @param page 分页对象
	 * @return PageInfo<Company>
	 * @throws Exception
	 */
	@RequestMapping("/list")
	@ResponseBody
	public PageInfo<SmsAdvice> list(SmsAdvice entity, PageInfo<SmsAdvice> page)
			throws Exception {
		return service.loadSmsAdviceInfo(page, entity);
	}
	 
	@RequestMapping("/view")
	public ModelAndView view(HttpServletRequest request) {
		return new ModelAndView("/sms/advice_list");
	}
}
